import { GaugeSurvey, QRActionApi } from '../../api';
export default class SurveyApiRealize {
  /**
   * 获取问卷详情
   * @param id 问卷id
   */
  public static getGaugeDetail = async (id: string) => {
    const { result } = await GaugeSurvey.getGaugeDetail({ id });
    return result;
  };

  /**
   * 获取编辑问卷缓存
   *
   */
  public static getCacheGauge = async (patientId: string, answerId: string) => {
    const { result } = await GaugeSurvey.getCacheGauge({ patientId, answerId });
    return result;
  };
  /**
   * 获取匿名问卷缓存
   */

  public static getUnknownCacheGauge = async () => {
    const { result } = await GaugeSurvey.getUnknownCacheGauge();
    return result;
  };

  /**
   * 获取原题目
   */
  public static getSurveyOriginal = async (data: { questionId?: string }) => {
    const { result } = await GaugeSurvey.getSurvey(data);
    return result;
  };
  /**
   * 获取扫码编辑问卷的信息，包括缓存信息
   */
  public static getQrCodeAnswerOrCache = async (code: string) => {
    const { result } = await GaugeSurvey.getQrCodeAnswerOrCache({ code });
    return result;
  };

  /**
   * 扫码进入获取相关信息
   * @param code
   */
  public static getQRCodeMsg = async (code: string) => {
    const { result } = await QRActionApi.getQRCodeMsg({ code });
    const gaugeData = {
      jsonDesc: result.questionVo.jsonDesc,
    };
    const surveyInfo = {
      visitNumber: result.visitNumber,
      answerJson: result.answerInfoVo.answerJson,
      gender: result.answerInfoVo.gender,
    };
    return { gaugeData, surveyInfo, result };
  };
}
